﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.DynamicData;
using System.Web.UI;

namespace DD_Bootstrap
{
	public static class NotAClueHelperExtensionMethods
	{
		/// <summary>
		/// Adds the startup client script.
		/// </summary>
		/// <param name="page">The page.</param>
		/// <param name="key">The key.</param>
		/// <param name="script">The script.</param>
		/// <param name="addScriptTags">if set to <c>true</c> [add script tags].</param>
		/// <remarks></remarks>
		public static void AddStartupClientScript(this Page page, String key, String script, Boolean addScriptTags = true)
		{
			// Define the name and type of the client scripts on the page.
			Type scriptType = page.GetType();

			// Get a ClientScriptManager reference from the Page class.
			ClientScriptManager csm = page.ClientScript;

			// Check to see if the Client Script Include is already registered.
			if (!csm.IsStartupScriptRegistered(scriptType, key))
			{
				// include main Flash Content script
				csm.RegisterStartupScript(scriptType, key, script, addScriptTags);
			}
		}
	}
}